// store/index.js
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    userName: localStorage.getItem('userName') || '默认昵称',
  }),
  actions: {
    updateUserName(newName) {
      this.userName = newName;
      localStorage.setItem('userName', newName);
    },
    initUser() {
      this.userName = localStorage.getItem('userName') || '默认昵称';
    }
  },
});
